import { ItemData } from "../../../resource/info/ItemData";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { PulseSharedObject } from "../../player/PulseSharedObject";
import { TodayNoTipsConst } from "../../../../component/gconst/TodayNoTipsConst";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { ToolTipUtil } from "../tooltip/util/ToolTipUtil";
import { PetUtil } from "../../pet/info/PetUtil";
import { EquipmentUtil } from "./EquipmentUtil";
import { Language } from "../../../../../extend/language/Language";
import { CheckBoxWin } from "../alertwins/CheckBoxWin";
type int = number;
//class GainItemUtil
    
    export  class GainItemUtil
    {
        

        public static gainItemTip(arg1: ItemData, arg2: Function, arg3: Object): void
        {
            var item: ItemData;
            var callBack: Function;
            var userObject: Object;
            var needTip: Boolean;
            var onGainTipAlertHandler: Function;

            var loc1;
            onGainTipAlertHandler = null;
            item = arg1;
            callBack = arg2;
            userObject = arg3;
            onGainTipAlertHandler = (arg1: int, arg2: Boolean): void
            {
                if (arg1 == Alert.CANCEL) 
                {
                    callBack(userObject);
                    PulseSharedObject.save(TodayNoTipsConst.IllustrateGainTodayNoTip, arg2);
                }
                return;
            }
            if (item == null || PulseSharedObject.isTodayNotTips(TodayNoTipsConst.IllustrateGainTodayNoTip)) 
            {
                callBack(userObject);
                return;
            }
            needTip = false;
            if (ItemsUtil.isIllustrate(item) && (ToolTipUtil.isActiveIllustrateByItemdata(item) || ToolTipUtil.isOwnIllustrateByItemdata(item))) 
            {
                needTip = true;
            }
            else if (ItemsUtil.isPetEgg(item) && PetUtil.isOwnPetByItemData(item)) 
            {
                needTip = true;
            }
            else if (ItemsUtil.isRune(item) && ToolTipUtil.isOwnRuneByItemData(item)) 
            {
                needTip = true;
            }
            else if (ItemsUtil.isAvatar(item) && ToolTipUtil.isOwnAvatarByItemdata(item)) 
            {
                needTip = true;
            }
            else if (ItemsUtil.isEquip(item) && EquipmentUtil.isOwnEquip(item) == 1) 
            {
                needTip = true;
            }
            if (needTip) 
            {
                Alert.okLabel = Language.getString(69901);
                Alert.calcelLabel = Language.getString(36319);
                Alert.alertWinRenderer = CheckBoxWin;
                Alert.show(Language.getString(36318), null, Alert.OK | Alert.CANCEL, null, onGainTipAlertHandler);
            }
            else 
            {
                callBack(userObject);
            }
            return;
        }
    }
